package cn.ycq.im.commons.exceptions;

import cn.ycq.im.commons.utils.Https;
import com.alibaba.fastjson.JSONObject;
import io.netty.handler.codec.http.FullHttpResponse;
import io.netty.handler.codec.http.HttpRequest;
import lombok.extern.slf4j.Slf4j;

@Slf4j
public class GlobalExceptionHandlers {
    public static void handler(HttpRequest req, FullHttpResponse res, Exception e) {

        log.error("调用方法失败", e);

        JSONObject jsonObject = new JSONObject();
        jsonObject.put("code","500");
        jsonObject.put("msg",e.getMessage());

        Https.ResponseUtils.writeJSON(res,jsonObject.toJSONString());
    }
}
